#!/bin/env bash 
# Dependencies: tesseract-ocr imagemagick gnome-screenshot xclip

#Name: OCR Picture
#Author:andrew
#Fuction: take a screenshot and OCR the letters in the picture
#Path: /home/Username/...
#Date: 2020-02-10

#you can only scan one character at a time
#SCR="/home/Username/Documents/temp"
SCR="/home/binxincao/文档/temp"

####take a shot what you wana to OCR to text
gnome-screenshot -a -f $SCR.png

####increase the png
mogrify -modulate 100,0 -resize 400% $SCR.png 
#should increase detection rate

####OCR by tesseract
tesseract $SCR.png $SCR &> /dev/null -l eng+chi1

####get the text and copy to clipboard
cat $SCR.txt | xclip -selection clipboard

# 结合翻译
#word=`cat $SCR.txt`
#mean=`sdcv -n ${word}`
#pkill notify-osd
#notify-send   "$mean"
#zenity --info --text="$mean" --width='600'  --timeout='20' --window-icon=/home/binxincao/.stardict/fanyi.jpg




cp $SCR.txt /home/binxincao/.cbx/ 
/usr/bin/python3.6 /home/binxincao/.cbx/fanyi.py

zenity --info --text="ok" --width='10'  --timeout='1'

exit
